class Plugin
{
	fun name(plugin : Plugin) -> string
	fun checkFile(plugin : Plugin, file : string) -> bool
}

fun name(plugin : Plugin) = "not defined"


// Zip implementation
struct ZipPlugin
{
	archive : ZipArchive
}
instance ZipPlugin : virtual Plugin

fun *ZipPlugin(archive : string)
{
	this.archive = ZipArchive(archive)
}

fun name(plugin : ZipPlugin) = "zip"

fun checkFile(plugin : ZipPlugin, file : string) = plugin.archive.containsFile(file)


// FTP implementation
struct FTPPlugin
{
	connection : FTPConnection
}
instance FTPPlugin : virtual Plugin

fun *FTPPlugin(server : string)
{
	this.connection = FTPConnection(server)
}

fun name(plugin : FTPPlugin) = "ftp"

fun checkFile(plugin : FTPPlugin, file : string) = plugin.connection.hasFile(file)


fun findFileInPlugins(plugins : Plugin[], file : string)
{
	for (plugin in plugins)
		if (plugin.checkFile(file))
			return &plugin
	
	return null
}

